//
//  MSEmployCell.m
//  觅尚
//
//  Created by No.8 on 2019/4/28.
//  Copyright © 2019 No.8. All rights reserved.
//

#import "MSEmployCell.h"

@implementation MSEmployCell

+ (instancetype)cellWithTableView:(UITableView *)tableView{
    MSEmployCell * cell = [tableView dequeueReusableCellWithIdentifier:[MSEmployCell ID]];
    cell = [[MSEmployCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:[MSEmployCell ID]];
    cell.backgroundColor = backgroundcolor;
    return cell;
}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self setMember];
        
    }
    return self;
}
- (void)setMember{
    /** 昵称*/
    self.NameLabel = [[UILabel alloc] initWithFrame:CGRectMake(50 * px, 30 * px, ScreenWidth / 2, 60 * px)];
    self.NameLabel.textColor = [UIColor whiteColor];
    self.NameLabel.text = @"000";
    self.NameLabel.textAlignment = NSTextAlignmentLeft;
    self.NameLabel.font = [UIFont systemFontOfSize:SYRealValue(32 / 2)];
    [self addSubview:self.NameLabel];
    
    /** 员工id*/
    self.IDLabel = [[UILabel alloc] initWithFrame:CGRectMake(self.NameLabel.x,CGRectGetMaxY(self.NameLabel.frame), ScreenWidth / 2, 50 * px)];
    self.IDLabel.textColor = [UIColor whiteColor];
    self.IDLabel.text = @"000";
    self.IDLabel.textAlignment = NSTextAlignmentLeft;
    self.IDLabel.font = [UIFont systemFontOfSize:SYRealValue(28 / 2)];
    [self addSubview:self.IDLabel];
    
    
    /** 注册时间*/
    self.RegisterLabel = [[UILabel alloc] initWithFrame:CGRectMake(self.NameLabel.x,CGRectGetMaxY(self.IDLabel.frame), ScreenWidth / 2, 40 * px)];
    self.RegisterLabel.textColor = [UIColor grayColor];
    self.RegisterLabel.text = @"000";
    self.RegisterLabel.textAlignment = NSTextAlignmentLeft;
    self.RegisterLabel.font = [UIFont systemFontOfSize:SYRealValue(24 / 2)];
    [self addSubview:self.RegisterLabel];
    
    
    /** 通过按钮*/
    self.AdoptButton = [[UIButton alloc] initWithFrame:CGRectMake(ScreenWidth - 210 * px, self.NameLabel.y, 180 * px, 60 * px)];
    [self.AdoptButton setTitle:@"通过" forState:UIControlStateNormal];
    self.AdoptButton.layer.cornerRadius = 30 * px;
    self.AdoptButton.layer.borderWidth = 1;
    self.AdoptButton.layer.borderColor = WYCRGBColor(72, 128, 224).CGColor;
    self.AdoptButton.titleLabel.font = [UIFont systemFontOfSize:SYRealValue(28 / 2)];
    [self.AdoptButton setTitleColor:WYCRGBColor(72, 128, 224) forState:UIControlStateNormal];
    [self.AdoptButton addTarget:self action:@selector(AdoptButtonClick) forControlEvents:UIControlEventTouchUpInside];
    [self addSubview:self.AdoptButton];
    
    
    /** 通过按钮*/
    self.NoAdoptButton = [[UIButton alloc] initWithFrame:CGRectMake(self.AdoptButton.x, CGRectGetMaxY(self.AdoptButton.frame) + 40 * px, self.AdoptButton.width, self.AdoptButton.height)];
    [self.NoAdoptButton setTitle:@"不通过" forState:UIControlStateNormal];
    self.NoAdoptButton.layer.cornerRadius = self.AdoptButton.layer.cornerRadius;
    self.NoAdoptButton.layer.borderWidth = 1;
    self.NoAdoptButton.layer.borderColor = WYCRGBColor(226, 88, 108).CGColor;
    self.NoAdoptButton.titleLabel.font = [UIFont systemFontOfSize:SYRealValue(28 / 2)];
    [self.NoAdoptButton setTitleColor:WYCRGBColor(226, 88, 108) forState:UIControlStateNormal];
    [self.NoAdoptButton addTarget:self action:@selector(NoAdoptButtonClick) forControlEvents:UIControlEventTouchUpInside];
    [self addSubview:self.NoAdoptButton];
    
    
    /** 分割线*/
    self.lineView = [[UILabel alloc] initWithFrame:CGRectMake(0, 220 * px, ScreenWidth, 1)];
    self.lineView.backgroundColor = BackViewColor;
    [self addSubview:self.lineView];
    
}
//同意
- (void)AdoptButtonClick{
    if (self.operationButtonDelegate && [self.operationButtonDelegate respondsToSelector:@selector(ButtonClickUid:)]) {
        [self.operationButtonDelegate ButtonClickUid:self.EmployeeModel.uid];
    }
    
}
//不同意
- (void)NoAdoptButtonClick{
    
    if (self.operationButtonDelegate && [self.operationButtonDelegate respondsToSelector:@selector(ButtonClickUid:)]) {
        [self.operationButtonDelegate ButtonClickUid:self.EmployeeModel.uid];
    }
}
- (void)setEmployeeModel:(MSEmployeeModel *)EmployeeModel{
    _EmployeeModel = EmployeeModel;
    
    double time = [EmployeeModel.createTime doubleValue] / 1000.0;
    
    NSDate *myDate = [NSDate dateWithTimeIntervalSince1970:time];
    
    NSDateFormatter *formatter = [NSDateFormatter new];
    
    [formatter setDateFormat:@"YYYY-MM-dd HH:mm:ss"];
    
    
    
    //将时间转换为字符串
    
    NSString *timeS = [formatter stringFromDate:myDate];
    
    self.NameLabel.text = [NSString stringWithFormat:@"%@ (%@/%@)",EmployeeModel.userName,EmployeeModel.stn_alias,EmployeeModel.pst_alias];
    
    self.IDLabel.text = [NSString stringWithFormat:@"员工ID:%@",EmployeeModel.uid];
    
    self.RegisterLabel.text = [NSString stringWithFormat:@"注册时间:%@",timeS];
}
+(NSString *)ID{
    return @"cell";
}
@end
